<?php

namespace App\Models;


use App\Service\Base\Model;
use Illuminate\Support\Facades\DB;

class UserMoney extends Model
{

    // 用户管理
    protected $table = 'user_money';

    // 缓存字段，用于搜索绑定的字段
    protected $cacheFields = ['id', 'uid', 'form_uid', 'type',];

    //  "id":"","uid":"用户ID","form_uid":"一级ID","total":"消费总数","money":"资金","type":"操作类型：auth：认证 order：订单 提现：withdraw","description":"描述","ctime":"注册时间","mtime":"更新时间"}


    // array ( 'id' => '$this->getData("id", null, "trim")', 'uid' => '$this->getData("uid", null, "trim")', 'form_uid' => '$this->getData("form_uid", null, "trim")', 'total' => '$this->getData("total", null, "trim")', 'money' => '$this->getData("money", null, "trim")', 'type' => '$this->getData("type", null, "trim")', 'description' => '$this->getData("description", null, "trim")', 'ctime' => '$this->getData("ctime", null, "trim")', 'mtime' => '$this->getData("mtime", null, "trim")', )


    //$id = $this->getData("id", null, 'trim'); $uid = $this->getData("uid", null, 'trim'); $form_uid = $this->getData("form_uid", null, 'trim'); $total = $this->getData("total", null, 'trim'); $money = $this->getData("money", null, 'trim'); $type = $this->getData("type", null, 'trim'); $description = $this->getData("description", null, 'trim'); $ctime = $this->getData("ctime", null, 'trim'); $mtime = $this->getData("mtime", null, 'trim');

    // 支付类型
    public function getType($getKey = true)
    {
        $channels = [
            'auth'     => '认证',
            'order'    => '订单',
            'withdraw' => '提现',
        ];

        if(empty($getKey)){
            return $channels;
        }

        return array_keys($channels);
    }


    // 定义验证操作
    public function rules()
    {

        $add = [
        ];

        $edit = [
        ];

        $info = [
        ];


        $rule = [
            'uid'         => 'required',
            'money'       => 'required',
            //'form_uid'    => 'required',
            //'total'       => 'required',
            'type'        => 'required',
            'description' => 'required',
        ];


        $msg = [
            'id'          => '',
            'uid'         => '用户ID',
            'form_uid'    => '一级ID',
            'total'       => '消费总数',
            'money'       => '资金',
            'type'        => '操作类型：auth：认证 order：订单 提现：withdraw',
            'description' => '描述',
            'ctime'       => '注册时间',
            'mtime'       => '更新时间',
        ];

        return ['rule' => $rule, 'msg' => $msg, 'add' => $add];
    }
}
